package com.esun.rabbit2.communicaters.sportterybasketball;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.sportterybasketball.SportteryBasketballAgainstInfo;
import com.esun.network.ServerCommunicater;

public class SportteryBasketballNoFilterAgainstInfoCommunicater extends ServerCommunicater {
	private String msgServer = ""; // 服务器信息
	private boolean isSucceed = false;

	private int type;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isGetInfoSucceed(int type) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		this.type = type;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_SPORTTERBASKETBALL_AGAINSTINFO_NOFILTER));
		list.add(mapItem(Key.KEY_TYPE, Integer.toString(type)));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			if (super.getListResult() == null || super.getListResult().equals(Config.NULLMARK) || super.getListResult().size() == 0) {
				isSucceed = false;
			} else {
				isSucceed = true;
			}
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public ArrayList<SportteryBasketballAgainstInfo> getAgainstInfoList() {

		ArrayList<SportteryBasketballAgainstInfo> listSportteryBasketballAgainstInfos = new ArrayList<SportteryBasketballAgainstInfo>();
		for (int i = 0; i < super.getListResult().size(); i++) {
			SportteryBasketballAgainstInfo sportteryBasketballAgainstInfo = new SportteryBasketballAgainstInfo();
			sportteryBasketballAgainstInfo.setMatchNum(super.getListResult().get(i).get(Key.KEY_MATCHNUM));
			sportteryBasketballAgainstInfo.setMatchNumDate(super.getListResult().get(i).get(Key.KEY_MATCHNUMDATE));
			sportteryBasketballAgainstInfo.setDayOfWeek(super.getListResult().get(i).get(Key.KEY_DAYOFWEEK));
			sportteryBasketballAgainstInfo.setId(super.getListResult().get(i).get(Key.KEY_ID));
			sportteryBasketballAgainstInfo.setSimpleLeague(super.getListResult().get(i).get(Key.KEY_SIMPLELEAGUE));
			sportteryBasketballAgainstInfo.setHomeSxName(super.getListResult().get(i).get(Key.KEY_HOMESXNAME));
			sportteryBasketballAgainstInfo.setAwaySxName(super.getListResult().get(i).get(Key.KEY_AWAYSXNAME));
			sportteryBasketballAgainstInfo.setPtggEndTime(super.getListResult().get(i).get(Key.KEY_PTGGENDTIME));
			sportteryBasketballAgainstInfo.setxId(super.getListResult().get(i).get(Key.KEY_XID));
			sportteryBasketballAgainstInfo.setProcessName(super.getListResult().get(i).get(Key.KEY_PROCESSNAME));

			if (type == 1 || type == 2) {
				sportteryBasketballAgainstInfo.setWin(super.getListResult().get(i).get(Key.KEY_WIN));
				sportteryBasketballAgainstInfo.setLost(super.getListResult().get(i).get(Key.KEY_LOST));
			}

			// else if (type == 3 || type == 4) {
			// sportteryBasketballAgainstInfo.setsZero(super.getListResult().get(i).get(Key.KEY_S0));
			// sportteryBasketballAgainstInfo.setsOne(super.getListResult().get(i).get(Key.KEY_S1));
			// sportteryBasketballAgainstInfo.setsTwo(super.getListResult().get(i).get(Key.KEY_S2));
			// sportteryBasketballAgainstInfo.setsThree(super.getListResult().get(i).get(Key.KEY_S3));
			// sportteryBasketballAgainstInfo.setsFour(super.getListResult().get(i).get(Key.KEY_S4));
			// sportteryBasketballAgainstInfo.setsFive(super.getListResult().get(i).get(Key.KEY_S5));
			// sportteryBasketballAgainstInfo.setsSix(super.getListResult().get(i).get(Key.KEY_S6));
			// sportteryBasketballAgainstInfo.setsSeven(super.getListResult().get(i).get(Key.KEY_S7));
			//
			// } else if (type == 5 || type == 6) {
			// updataScoreInfo(sportteryBasketballAgainstInfo, i);
			//
			// } else if (type == 7 || type == 8) {
			// sportteryBasketballAgainstInfo.setAa(super.getListResult().get(i).get(Key.KEY_AA));
			// sportteryBasketballAgainstInfo.setAb(super.getListResult().get(i).get(Key.KEY_AB));
			// sportteryBasketballAgainstInfo.setAc(super.getListResult().get(i).get(Key.KEY_AC));
			// sportteryBasketballAgainstInfo.setBa(super.getListResult().get(i).get(Key.KEY_BA));
			// sportteryBasketballAgainstInfo.setBb(super.getListResult().get(i).get(Key.KEY_BB));
			// sportteryBasketballAgainstInfo.setBc(super.getListResult().get(i).get(Key.KEY_BC));
			// sportteryBasketballAgainstInfo.setCa(super.getListResult().get(i).get(Key.KEY_CA));
			// sportteryBasketballAgainstInfo.setCb(super.getListResult().get(i).get(Key.KEY_CB));
			// sportteryBasketballAgainstInfo.setCc(super.getListResult().get(i).get(Key.KEY_CC));

			// }
			else {

			}

			listSportteryBasketballAgainstInfos.add(sportteryBasketballAgainstInfo);
		}
		return listSportteryBasketballAgainstInfos;
	}

	// /**
	// * @Title: updataScoreInfo
	// * @Description: 导入type为比分时的数据
	// * @param: @param sportteryBasketballAgainstInfo
	// * @param: @param i 设定文件
	// * @return: void 返回类型
	// * @throws
	// */
	// private void updataScoreInfo(SportteryBasketballAgainstInfo sportteryBasketballAgainstInfo, int i) {
	// sportteryBasketballAgainstInfo.setaOneZero(super.getListResult().get(i).get(Key.KEY_A10));
	// sportteryBasketballAgainstInfo.setaTwoZero(super.getListResult().get(i).get(Key.KEY_A20));
	// sportteryBasketballAgainstInfo.setaTwoOne(super.getListResult().get(i).get(Key.KEY_A21));
	// sportteryBasketballAgainstInfo.setaThreeZero(super.getListResult().get(i).get(Key.KEY_A30));
	// sportteryBasketballAgainstInfo.setaThreeOne(super.getListResult().get(i).get(Key.KEY_A31));
	// sportteryBasketballAgainstInfo.setaThreeTwo(super.getListResult().get(i).get(Key.KEY_A32));
	// sportteryBasketballAgainstInfo.setaFourZero(super.getListResult().get(i).get(Key.KEY_A40));
	// sportteryBasketballAgainstInfo.setaFourOne(super.getListResult().get(i).get(Key.KEY_A41));
	// sportteryBasketballAgainstInfo.setaFourTwo(super.getListResult().get(i).get(Key.KEY_A42));
	// sportteryBasketballAgainstInfo.setaFiveZero(super.getListResult().get(i).get(Key.KEY_A50));
	// sportteryBasketballAgainstInfo.setaFiveOne(super.getListResult().get(i).get(Key.KEY_A51));
	// sportteryBasketballAgainstInfo.setaFiveTwo(super.getListResult().get(i).get(Key.KEY_A52));
	// sportteryBasketballAgainstInfo.setaOther(super.getListResult().get(i).get(Key.KEY_AOTHER));
	//
	// sportteryBasketballAgainstInfo.setcZeroZero(super.getListResult().get(i).get(Key.KEY_C00));
	// sportteryBasketballAgainstInfo.setcOneOne(super.getListResult().get(i).get(Key.KEY_C11));
	// sportteryBasketballAgainstInfo.setcTwoTwo(super.getListResult().get(i).get(Key.KEY_C22));
	// sportteryBasketballAgainstInfo.setcThreeThree(super.getListResult().get(i).get(Key.KEY_C33));
	// sportteryBasketballAgainstInfo.setcOther(super.getListResult().get(i).get(Key.KEY_COTHER));
	//
	// sportteryBasketballAgainstInfo.setbOneZero(super.getListResult().get(i).get(Key.KEY_B10));
	// sportteryBasketballAgainstInfo.setbTwoZero(super.getListResult().get(i).get(Key.KEY_B20));
	// sportteryBasketballAgainstInfo.setbTwoOne(super.getListResult().get(i).get(Key.KEY_B21));
	// sportteryBasketballAgainstInfo.setbThreeZero(super.getListResult().get(i).get(Key.KEY_B30));
	// sportteryBasketballAgainstInfo.setbThreeOne(super.getListResult().get(i).get(Key.KEY_B31));
	// sportteryBasketballAgainstInfo.setbThreeTwo(super.getListResult().get(i).get(Key.KEY_B32));
	// sportteryBasketballAgainstInfo.setbFourZero(super.getListResult().get(i).get(Key.KEY_B40));
	// sportteryBasketballAgainstInfo.setbFourOne(super.getListResult().get(i).get(Key.KEY_B41));
	// sportteryBasketballAgainstInfo.setbFourTwo(super.getListResult().get(i).get(Key.KEY_B42));
	// sportteryBasketballAgainstInfo.setbFiveZero(super.getListResult().get(i).get(Key.KEY_B50));
	// sportteryBasketballAgainstInfo.setbFiveOne(super.getListResult().get(i).get(Key.KEY_B51));
	// sportteryBasketballAgainstInfo.setbFiveTwo(super.getListResult().get(i).get(Key.KEY_B52));
	// sportteryBasketballAgainstInfo.setbOther(super.getListResult().get(i).get(Key.KEY_BOTHER));
	//
	// }

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
